#include <stdio.h>

int find_missing_seq_num(int *a, int len)
{
	int s = 0, e = len-1, mid = 0;
	while(e > s) {
		mid = (s+e)/2;
		printf("s %d, mid %d, end %d, a[mid] %d, a[e] %d\n", s, mid, e, a[mid], a[e]);
		if (e - mid != a[e] - a[mid]){
			s = mid;
		} else {
			e = mid;
		}
		if (s+1 == e)
			return a[s]+1;
	}
	return -1;
}
void main(void)
{
	int i = 0;
	int a[100];
	for (i = 0; i <= 46; i++){
		a[i] = i+1;
	} 
	for (i = 47; i < 100; i++){
		a[i] = i+2;
	}
	for (i = 0; i < 100; i++)
	printf("%d ", a[i]); 
	int ret = find_missing_seq_num(a, sizeof(a)/sizeof(a[0]));
	printf("missing one is %d\n", ret);
}
